package com.ffdms.mobileoffice;

import java.util.ArrayList;
import java.util.List;

import com.ffdms.util.Constant;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.AdapterView.OnItemClickListener;

public class PlanDashboardActivity extends BaseActivity implements
		OnItemClickListener {
	private GridView mGridView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_plan_dashboard);
		init();

	}

	private void init() {
		mGridView = (GridView) findViewById(R.id.plan_home_gridview);
		installDashboard();
	}

	private void installDashboard() {
		final List<PlanDashboardInfo> plans = new ArrayList<PlanDashboardInfo>();
		PlanDashboardInfo single_plan = new PlanDashboardInfo();
		single_plan.setImg(R.drawable.plan_week);
		single_plan.setTitle("周计划");
		single_plan.setType(Constant.PlanDashboardActionType.PLAN_WEEK);
		plans.add(single_plan);

		single_plan = new PlanDashboardInfo();
		single_plan.setImg(R.drawable.plan_month);
		single_plan.setTitle("月计划");
		single_plan.setType(Constant.PlanDashboardActionType.PLAN_MONTH);
		plans.add(single_plan);

		single_plan = new PlanDashboardInfo();
		single_plan.setImg(R.drawable.plan_year);
		single_plan.setTitle("年计划");
		single_plan.setType(Constant.PlanDashboardActionType.PLAN_YEAR);
		plans.add(single_plan);

		single_plan = new PlanDashboardInfo();
		single_plan.setImg(R.drawable.plan_user_defined);
		single_plan.setTitle("自定义计划");
		single_plan.setType(Constant.PlanDashboardActionType.PLAN_CUSTOM);
		plans.add(single_plan);

		single_plan = new PlanDashboardInfo();
		single_plan.setImg(R.drawable.plan_readandappraise);
		single_plan.setTitle("评阅计划");
		single_plan.setType(Constant.PlanDashboardActionType.PLAN_REVIEW);
		plans.add(single_plan);

		single_plan = new PlanDashboardInfo();
		single_plan.setImg(R.drawable.work_log);
		single_plan.setTitle("工作日志");
		single_plan.setType(Constant.PlanDashboardActionType.PLAN_WORK_LOG);
		plans.add(single_plan);
		PlanDashboardListAdapter adp = new PlanDashboardListAdapter(this, plans);
		mGridView.setAdapter(adp);
		mGridView.setOnItemClickListener(this);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		PlanDashboardInfo plan = (PlanDashboardInfo) arg0
				.getItemAtPosition(arg2);
		Intent intent_plandetail = new Intent(PlanDashboardActivity.this,
				PlanDetailActivity.class);
		intent_plandetail.putExtra(
				Constant.IntentRepresent.INTENT_PLAN_DETAIL_TITLE,
				plan.getTitle());
		// t.putExtra("type", n.getType());
		startActivity(intent_plandetail);
	}

}
